<div onClick="addMaterial();">เพิ่ม</div>
<?php 
	include("db/connect.php");
	$sqlselectstruc="select * from usematerial,material where material.mat_id=usematerial.mat_id and pro_id=".$_GET['pro_id'];
	$queryselectstruc=mysql_query($sqlselectstruc);
 ?>
<form name="form1" method="post" action="">
  <table width="200" border="1">
  <thead>
    <tr>
      <th>ชื่อวัตถุดิบ</th>
      <th>จำนวน</th>
      <th>หน่วย</th>
      <th>ลบ</th>
    </tr>
    </thead>
    <tbody>
    <?php 
  while($resultselectstruc=mysql_fetch_array($queryselectstruc)){
  ?>
    <tr>
      <td><?php echo $resultselectstruc["mat_name"]?></td>
      <td><?php echo $resultselectstruc["use_qty"]?></td>
      <td><?php echo $resultselectstruc["mat_unit"]?></td>
      <td><a href="Javascript:if(window.confirm('ยืนยันการลบ'))dltMaterial(<?php echo $resultselectstruc["use_id"]?>);">ลบ</a></td>
    </tr> <?php } ?>
    </tbody>
  </table>
</form>
<script>
function addMaterial(){
	$.ajax({
		url:"insert_strucmaterial.php?pro_id=<?php echo $_GET['pro_id'] ?>"
		,success: function(msg){
			$("#struc").html(msg);
			}
		});
	}
	function dltMaterial(use_id){
	$.ajax({
		url:"dltstruc.php?use_id="+use_id
		,success: function(msg){
		$("#struc").load('strucmaterial.php?pro_id=<?php echo $_GET['pro_id'] ?>');
			}
		});
	}
</script>